package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_Product 产品
 *
 */
public class TestData_TB_Product
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_Product saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ProductCategory productCategory
	,bairui.international.model.domain.jpa.TB_ProductCategory rootCategory
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_Product");
		return (TB_Product)repository.save(newMust(
				productCategory
				,rootCategory
			));
	}
	
	public static TB_Product newMust(
		bairui.international.model.domain.jpa.TB_ProductCategory productCategory
	,bairui.international.model.domain.jpa.TB_ProductCategory rootCategory
	){
		return new TB_Product(new TB_Product.MustProperties() {
			/** 代码 */
			@Override public String getNumber(){
				return Generator.generate(0, 32);
			}
			/** 名称 */
			@Override public String getName(){
				return Generator.generate(0, 255);
			}
			/** 价格 */
			@Override public Double getPrice(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
			}
			/** 产品分类 */
			@Override public bairui.international.model.domain.jpa.TB_ProductCategory getProductCategory(){
				return productCategory;
			}
			/** 状态 */
			@Override public bairui.international.model.status.State_Product getState(){
				return bairui.international.model.status.State_Product.Draft;
			}
			/** 产品根分类 */
			@Override public bairui.international.model.domain.jpa.TB_ProductCategory getRootCategory(){
				return rootCategory;
			}
			/** 积分 */
			@Override public Double getScore(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(Long.MIN_VALUE, Long.MAX_VALUE);
			}
			/** 分成比率[%] */
			@Override public Double getDivideRate(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, 100);
			}
			/** 兑换积分值 */
			@Override public Double getExchange(){
				return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_Product saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_ProductCategory productCategory
	,bairui.international.model.domain.jpa.TB_ProductCategory rootCategory
	,bairui.international.model.domain.jpa.TB_WineBottleNorms wineBottleNormsWine
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_Product");
		return (TB_Product)repository.save(newAll(
				productCategory
				,rootCategory
				,wineBottleNormsWine
			));
	}
	
	public static TB_Product newAll(
		bairui.international.model.domain.jpa.TB_ProductCategory productCategory
	,bairui.international.model.domain.jpa.TB_ProductCategory rootCategory
	,bairui.international.model.domain.jpa.TB_WineBottleNorms wineBottleNormsWine
	){
		return new TB_Product(
			new TB_Product.MustProperties() {
				/** 代码 */
				@Override public String getNumber(){
					return Generator.generate(0, 32);
				}
				/** 名称 */
				@Override public String getName(){
					return Generator.generate(0, 255);
				}
				/** 价格 */
				@Override public Double getPrice(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
				}
				/** 产品分类 */
				@Override public bairui.international.model.domain.jpa.TB_ProductCategory getProductCategory(){
					return productCategory;
				}
				/** 状态 */
				@Override public bairui.international.model.status.State_Product getState(){
					return bairui.international.model.status.State_Product.Draft;
				}
				/** 产品根分类 */
				@Override public bairui.international.model.domain.jpa.TB_ProductCategory getRootCategory(){
					return rootCategory;
				}
				/** 积分 */
				@Override public Double getScore(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(Long.MIN_VALUE, Long.MAX_VALUE);
				}
				/** 分成比率[%] */
				@Override public Double getDivideRate(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, 100);
				}
				/** 兑换积分值 */
				@Override public Double getExchange(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
				}
			},
			new TB_Product.OptionalSingleProperties() {
				/** 尊享价 */
				@Override public Double getShowPrice(){
					return com.sh_lianjing.test.random.Util_GenerateRandom.doubleRandom(0, Long.MAX_VALUE);
				}
				/** 备注 */
				@Override public String getComment(){
					return Generator.generate(0, 500);
				}
				/** 详情 */
				@Override public String getDetail(){
					return Generator.generate(0, 20000);
				}
				/** 图片 */
				@Override public String getImgUrl(){
					return Generator.generate(0, 500);
				}
				/** 酒瓶规格_酒 */
				@Override public bairui.international.model.domain.jpa.TB_WineBottleNorms getWineBottleNormsWine(){
					return wineBottleNormsWine;
				}
			}
		);
	}
	

}
